<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/animate.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 100px;
            height: 100px;
            background-color: #6ff;
            margin: 10px 0;
        }
    </style>
</head>

<body>
    <div class="box">01</div>
    <div class="box">02</div>
    <div class="box">03</div>

    <button>01</button>
    <button>02</button>
    <button>03</button>
</body>
<script>

    // 多物体运动  需要将计时器绑在元素上
    var boxList = document.querySelectorAll(".box");
    var btnList = document.querySelectorAll("button");

    animate(boxList[0], "marginLeft", 1000, "linear");
    animate(boxList[1], "marginLeft", 600, "ease-in");
    animate(boxList[2], "marginLeft", 800, "ease-out");

    btnList[0].onclick = function () {
        clearInterval(boxList[0].timer);
    }
</script>

</html>